
<{include file="www/header.tpl"}>
<{include file="www/header-base.tpl"}>

<div class="top-banner">
    <img class="img" src="/resource/www/imgs/search_activity.jpg">
    <p class="info">寻找你感兴趣的活动</p>
    <div class="content-search">
        <form class="search-form" action="/activity/search">
            <select name="country" id="" class="city" >
                <option value="-1">选择国家</option>
                <{foreach from=$countrys item="country"}>
                <option value="<{$country.val}>" <{if $country.selected == 2}>selected<{/if}>><{$country.val}></option>
                <{/foreach}>
            </select>
            <select class="city" name="city" id="city">
                <option value="-1">选择城市</option>
                <{foreach from=$scitys item=scity}>
                <option value="<{$scity.val}>" <{if $scity.selected == 2}>selected<{/if}>><{$scity.val}></option>
                <{/foreach}>
            </select>
            <input class="go-date" type="text" name="start"  value="<{$start}>"  id="start" placeholder="出发日期">
            <input class="back-date" type="text" name="end" id="end" value="<{$end}>" id="end" placeholder="返回日期">
            <select class="number" name="number" id="number">
                <{section name=loop loop=15}>
                    <option  value="<{$smarty.section.loop.index+1}>"
                <{if $number == ($smarty.section.loop.index+1)}>selected<{/if}>>
                                    <{$smarty.section.loop.index+1}>位游客
                    </option>
                <{/section}>
            </select>
            <input class="submit" type="submit" value="活动搜索">
        </form>
    </div>
</div>

<div class="center-main fix">
    <div class="sidebar">
        <form>
            <div class="condition">
                <p class="title"  onclick="menu_func(this);">
                    <i class="icon-down"></i>
                    发布者
                </p>
                <ul class="ul">
                    <li class="li">
                        <label class="fix">
                            <em class="left all"></em>
                            <span class="center">全部</span>
                            <input class="right" type="radio"  name="fabu" <{if $fabu == '0'}>checked<{/if}> value="0" id="">
                        </label>
                    </li>
                    <li class="li">
                        <label class="fix">
                            <em class="left ziying"></em>
                            <span class="center">哇吖自营</span>
                            <input class="right" type="radio" name="fabu" <{if $fabu == -10}>checked<{/if}>  value="-10" id="">
                        </label>
                    </li>
                    <li class="li">
                        <label class="fix">
                            <em class="left daoyou"></em>
                            <span class="center">导游发布</span>
                            <input class="right" type="radio" name="fabu" <{if $fabu == 1}>checked<{/if}> value="1" id="">
                        </label>
                    </li>
                </ul>
            </div>
            <div class="condition">
                <p class="title"  onclick="menu_func(this);">
                    <i class="icon-down"></i>
                    年龄
                </p>
                <ul class="ul">
                    <li class="li">
                        <label class="fix">
                            <em class="left all"></em>
                            <span class="center">全部</span>
                            <input class="right" type="radio" name="age" <{if $age == -1}>checked<{/if}> value="-1">
                        </label>
                    </li>
                    <li class="li">
                        <label class="fix">
                            <em class="left"></em>
                            <span class="center">70后</span>
                            <input class="right" type="radio" name="age" <{if $age == 70}>checked<{/if}> value="70">
                        </label>
                    </li>
                    <li class="li">
                        <label class="fix">
                            <em class="left"></em>
                            <span class="center">80后</span>
                            <input class="right" type="radio" name="age" <{if $age == 80}>checked<{/if}> value="80">
                        </label>
                    </li>
                    <li class="li">
                        <label class="fix">
                            <em class="left"></em>
                            <span class="center">90后</span>
                            <input class="right" type="radio" name="age" <{if $age == 90}>checked<{/if}> value="90">
                        </label>
                    </li>
                    <li class="li">
                        <label class="fix">
                            <em class="left"></em>
                            <span class="center">00后</span>
                            <input class="right" type="radio" name="age" <{if $age == '00'}>checked<{/if}> value="00">
                        </label>
                    </li>
                </ul>
            </div>
            <div class="condition">
                <p class="title"  onclick="menu_func(this);">
                    <i class="icon-down"></i>
                    性别
                </p>
                <ul class="ul">
                    <li class="li">
                        <label class="fix">
                            <em class="left all"></em>
                            <span class="center">全部</span>
                            <input class="right" type="radio" name="gender" <{if $gender == '0'}>checked<{/if}>  value="0" id="">
                        </label>
                    </li>
                    <li class="li">
                        <label class="fix">
                            <em class="left boy"></em>
                            <span class="center">男生</span>
                            <input class="right" type="radio" name="gender" <{if $gender == 'm'}>checked<{/if}> value="m" id="">
                        </label>
                    </li>
                    <li class="li">
                        <label class="fix">
                            <em class="left girl"></em>
                            <span class="center">女生</span>
                            <input class="right" type="radio" name="gender" <{if $gender == 'f'}>checked<{/if}> value="f" id="">
                        </label>
                    </li>
                </ul>
            </div>
            <div class="condition">
                <p class="title"  onclick="menu_func(this);">
                    <i class="icon-down"></i>
                    身份
                </p>
                <ul class="ul">
                    <li class="li">
                        <label class="fix">
                            <em class="left all"></em>
                            <span class="center">全部</span>
                            <input class="right" type="radio" name="identity" <{if $identity == '0'}>checked<{/if}> value="0" id="">
                        </label>
                    </li>
                    <li class="li">
                        <label class="fix">
                            <em class="left lxs"></em>
                            <span class="center">留学生</span>
                            <input class="right" type="radio" name="identity" <{if $identity == '留学生'}>checked<{/if}> value="留学生" id="">
                        </label>
                    </li>
                    <li class="li">
                        <label class="fix">
                            <em class="left china"></em>
                            <span class="center">当地华人</span>
                            <input class="right" type="radio" name="identity" <{if $identity == '当地华人'}>checked<{/if}> value="当地华人" id="">
                        </label>
                    </li>
                    <li class="li">
                        <label class="fix">
                            <em class="left wgr"></em>
                            <span class="center">外国人</span>
                            <input class="right" type="radio" name="identity" <{if $identity == '外国人'}>checked<{/if}> value="外国人"  id="">
                        </label>
                    </li>
                </ul>
            </div>
            <div class="condition">
                <p class="title"  onclick="menu_func(this);">
                    <i class="icon-down"></i>
                    语言
                </p>
                <ul class="ul">
                    <li class="li">
                        <label class="fix">
                            <em class="left all"></em>
                            <span class="center">全部</span>
                            <input class="right" type="radio" name="language" <{if $language == '0'}>checked<{/if}> value="0" id="">
                        </label>
                    </li>
                    <li class="li">
                        <label class="fix">
                            <em class="left uk"></em>
                            <span class="center">英语</span>
                            <input class="right" type="radio" name="language" <{if $language == '3'}>checked<{/if}> value="3" id="">
                        </label>
                    </li>
                    <li class="li">
                        <label class="fix">
                            <em class="left cn"></em>
                            <span class="center">普通话</span>
                            <input class="right" type="radio" name="language" <{if $language == '1'}>checked<{/if}> value="1" id="">
                        </label>
                    </li>
                    <li class="li">
                        <label class="fix">
                            <em class="left fr"></em>
                            <span class="center">法语</span>
                            <input class="right" type="radio" name="language" <{if $language == '2'}>checked<{/if}> value="2" id="">
                        </label>
                    </li>
                </ul>
            </div>
            <div class="condition">
                <p class="title"  onclick="menu_func(this);">
                    <i class="icon-down"></i>
                    人数上限
                </p>

                <div class="taskBox ul">
                    <div class="taskBoxLinks-wrap">
                        <div class="taskBoxLinks">
                            <div class="taskBoxStart" style="width: 0%;"></div>
                        </div>
                        <div class="taskBoxBtn" style="left: 0%;"></div>
                        <div class="numberBox">
                            <span class="numberStart">1人</span>
                            <span class="numberGuoc"></span>
                            <span class="numberEnd">15人</span>
                        </div>
                        <input type="hidden" name="persons" id="people_num" value="" class="canynumber">
                    </div>
                </div>

            </div>

            <div class="customize fix">
                <div class="left">
                    <img class="img" src="/resource/www/imgs/customize_help.png" alt="">
                </div>
                <div class="right">
                    <p class="title">哇吖定制服务</p>
                    <a target="_blank" href="/customize/" class="go-click">没有找到合适的路线？请点击 &gt;</a>
                </div>
            </div>
        </form>
    </div>
    <div class="content">
        <div class="info-bar fix">
            <span class="jieguo">已为您搜索到<{$counts}>条热门活动</span>
               <span id="price" class="price" onclick="sort_menu(this, 'em');">
                价格 <{if $price == 2}>
                <em class="icon-up"></em>
               <input type="hidden" name="price" value="2">
                <{else}>
                <em class="icon-down"></em>
               <input type="hidden" name="price" value="1">
                   <{/if}>
            </span>
            <span id="orders" class="order-number" onclick="sort_menu(this, 'em');">
                成单数  <{if $orders == 2}>
                <em class="icon-up"></em>
            <input type="hidden" name="orders" value="2">
                <{else}>
                <em class="icon-down"></em>
            <input type="hidden" name="orders" value="1">
                <{/if}>
            </span>
            <span  id="score" class="score" onclick="sort_menu(this, 'em');">
                评分<{if $score == 2}>
              <em class="icon-up"></em>
            <input type="hidden" name="score" value="2">
                <{else}>
             <em class="icon-down"></em>
            <input type="hidden" name="score" value="1">
                <{/if}>
            </span>
        </div>
        <{if $counts > 0}>
        <ul class="activity-other loading fix">
            <{foreach from=$list item=v}>
            <li class="li">
                <a class="a" target="_blank" href="/activity/detail/<{$v.id}>">
                    <img class="img" src="<{$v.thumb}>">
                    <img class="tx" src="<{$v.guider.userIcon}>">
                    <{if $v.guider.userUid == 1}>
                    <em class="p-icon"></em>
                    <{/if}>
                    <p class="title"><{$v.location}></p>
                    <div class="detail">
                        <p class="info">由<{$v.guider.realName}>发起</p>
                        <p class="local"><em></em><!--30分钟--><{$v.hours}>小时 <em></em><{$v.city}></p>
                        <p class="text"><{$v.name}></p>
                    </div>
                    <p class="bottom-info fix">
                        <span class="left">
                              <{if $v.score == 0}>
                            <span style="color: #000">暂无评分</span>
                            <{else}>
                        <img class="score" src="/resource/www/imgs/score_<{$v.score/100|floor}>.png">
                            <em class="number">(<{$v.score/100}>分)</em>
                            <{/if}>

                        </span>
                        <span class="right">
                            <{$v.priceService/100*1.1|round:2}>€ / 人
                        </span>
                    </p>
                </a>
            </li>
            <{/foreach}>
            <{/if}>

        </ul>
        <{$pagination}>
    </div>
</div>
<script type="text/javascript">
            var contentsearchOY = $("div.content-search").offset().top;
$(window).scroll(function(){
            var contentsearchY=contentsearchOY-$(document).scrollTop();
            if(contentsearchY<=0){
            $("div.content-search").removeAttr("style");
            $("div.content-search").css({"position":"fixed","top":0,"left":0});
            }else if(contentsearchY>0){
            $("div.content-search").removeAttr("style");
            $("div.content-search").css({"position":"absolute","bottom":0,"left":0});
            }
});
</script>

<script>
    $(function(){
        $("input[type='radio']").click(function() {
            search_condition();
        });
        $("#persons").change(function() {
            search_condition();
        });


        $(".taskBoxLinks-wrap").click(function() {
            search_condition();
        });


        $('#price').click(function() {
            $("input[name='orders']").val(0);
            $("input[name='score']").val(0);
            search_condition();
        });

        $('#orders').click(function() {
            $("input[name='price']").val(0);
            $("input[name='score']").val(0);
            search_condition();
        });

        $('#score').click(function() {
            $("input[name='price']").val(0);
            $("input[name='orders']").val(0);
            search_condition();
        });
        
        $("select[name='country']").change(function(){
	$.ajax({
        url:'/trackajax/ajax_getCitysByCountry',
        data:{country:$(this).val()},
        type:'post',
        success:function(data){
           data = eval('('+data+')');
           var str='<option  value="-1">选择城市</option>';
           var x;
           for(x in data){
           str+='<option value='+data[x]+'>'+data[x]+'</option>';
           } 
            $("select[name='city']").html(str);}
         });
        });

        function search_condition(){

            var fabu = $("input[name='fabu']:checked").val();
            var age = $("input[name='age']:checked").val();
            var gender = $("input[name='gender']:checked").val();
            var identity = $("input[name='identity']:checked").val();
            var language = $("input[name='language']:checked").val();
            var chuxing = $("input[name='chuxing']:checked").val();
            var person =  $("#persons").val();
            var city = $("#city").val();
            var start = $("#start").val();
            var end = $("#end").val();
            var number = $("#number").val();
            var people_num = $("#people_num").val();
            var price = $("input[name='price']").val();
            var orders = $("input[name='orders']").val();
            var score = $("input[name='score']").val();
//            var chuxing = $("input[name='chuxing']:checked").val();
//            var chuxing = $("input[name='chuxing']:checked").val();

            var get_query = "?";
            if(typeof(city) != "undefined" && city != '' && city != null){
                get_query += "city="+city+"&";
            }
            if(typeof(person) != "undefined" && person != '' && person != null){
                get_query += "person="+person+"&";
            }

            if(typeof(start) != "undefined" && start != ''){
                get_query += "start="+start+"&";
            }
            if(typeof(end) != "undefined" && end != ''){
                get_query += "end="+end+"&";
            }

            if(typeof(number) != "undefined" && number != -1){
                get_query += "number="+number+"&";
            }

            if(typeof(fabu) != "undefined" && fabu != ''){
                get_query += "fabu="+fabu+"&";
            }

            if(typeof(age) != "undefined" && age != ''){
                get_query += "age="+age+"&";
            }

            if(typeof(gender) != "undefined" && gender != ''){
                get_query += "gender="+gender+"&";
            }

            if(typeof(identity) != "undefined" && identity != ''){
                get_query += "identity="+identity+"&";
            }

            if(typeof(language) != "undefined" && language != ''){
                get_query += "language="+language+"&";
            }

            if(typeof(chuxing) != "undefined" && chuxing != ''){
                get_query += "chuxing="+chuxing+"&";
            }

            if(typeof(people_num) != "undefined" && people_num != '' && people_num != null){
                get_query += "people_num="+people_num+"&";
            }

            if(typeof(price) != "undefined" && price != '' && price != 0 && price != null){
                get_query += "price="+price+"&";
            }

            if(typeof(orders) != "undefined" && orders != '' && orders != 0 && orders != null){
                get_query += "orders="+orders+"&";
            }

            if(typeof(score) != "undefined" && score != '' && score != 0 && score != null){
                get_query += "score="+score+"&";
            }

            var query_string = get_query.substring(0,get_query.length-1);
            var url  = '/activity/search'+query_string;
            location.href = url;

        }
    })

function menu_func(item) {

    if ($(item).parent().find('.ul').is(":hidden")) {
        $(item).find('i').removeClass('up-down').addClass('icon-down');
    } else {
        $(item).find('i').removeClass('icon-down').addClass('up-down');
    }
    $(item).parent().find('.ul').slideToggle();
}

function sort_menu(item, ele) {

    if ($(item).find(ele).hasClass('icon-down')) {
        $(item).find(ele).removeClass('icon-down').addClass('icon-up');
        $(item).find('input').val(2);
    } else {
        $(item).find(ele).removeClass('icon-up').addClass('icon-down');
        $(item).find('input').val(1);
    }
}

(function() {
    var statu = false;
    var ox = 0;
    var lx = 0;
    var left = 0;
    var bgleft = 0;

    var $box = $('.taskBoxLinks-wrap');
    var $btn = $('.taskBoxBtn');
    var $bgcolor = $('.taskBoxStart');
    var $bg = $('.taskBoxLinks');
    var $Guoc = $('.numberGuoc');
    $box.mousedown(function(e) {
        lx = $btn.offset().left;
        ox = e.pageX - left;
        statu = true;

        $box.mousemove(function(e) {
            if (statu) {
                left = e.pageX - ox;
                var endNumber =  Math.round(( left / 210 ) * 15);

                if (endNumber < 1) {
                    endNumber = 1;
                }
                if (endNumber > 15) {
                    endNumber = 15;
                }
                if (left < 0) {
                    left = 0;
                }
                if (left > 210) {
                    left = 210;
                }
                $btn.css('left', left);
                $bgcolor.width(left);
                $Guoc.html('参与人数' + endNumber + '人');
                $('.canynumber').attr('value', endNumber);
            }
        });

        $(document).mouseup(function() {
            // $box.unbind();
            statu = false;
        });

    });

    $bg.click(function(e) {
        if (!statu) {
            bgleft = $bg.offset().left;
            left = e.pageX - bgleft;
            var endNumber =  Math.round( ( left / 210 ) * 15 );

            if (endNumber < 1) {
                endNumber = 1;
            }
            if (endNumber > 15) {
                endNumber = 15;
            }
            if (left < 0) {
                left = 0;
            }
            if (left > 210) {
                left = 210;
            }

            $btn.css('left', left);

            $Guoc.html('参与人数' + endNumber + '人');
            $('.canynumber').attr('value', endNumber);
            $bgcolor.stop().animate({
                width: left
            }, 200);
        }
    });

})();

</script>

<{include file="www/widget_calendar.tpl"}>
<{include file="www/footer.tpl"}>
